/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.goods.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.file.utils.FileUploadUtils;
import com.jeesite.modules.goods.dao.ZtBackImgDao;
import com.jeesite.modules.goods.entity.ZtBackImg;

/**
 * 测试数据Service
 * 
 * @author ThinkGem
 * @version 2018-04-22
 */
@Service
@Transactional(readOnly = true)
public class ZtBackImgService extends CrudService<ZtBackImgDao, ZtBackImg> {
	
	public List<ZtBackImg> findMh(ZtBackImg ztBackImg){
		return dao.findMh(ztBackImg);
	}
	
	/**
	 * 获取单条数据
	 * 
	 * @param testData
	 * @return
	 */
	@Override
	public ZtBackImg get(ZtBackImg ztBackImg) {
		ZtBackImg entity = super.get(ztBackImg);
		if (entity == null) {
			entity = new ZtBackImg();
		}
		return entity;
	}
	public ZtBackImg getMh(ZtBackImg ztBackImg) {
		ZtBackImg entity =dao.getMh(ztBackImg);
		if (entity == null) {
			entity = new ZtBackImg();
		}
		return entity;
	}
	
	/**
	 * 查询分页数据
	 * 
	 * @param page
	 *            分页对象
	 * @param testData
	 * @return
	 */
	@Override
	public Page<ZtBackImg> findPage(Page<ZtBackImg> page, ZtBackImg ZtBackImg) {
		return super.findPage(page, ZtBackImg);
	}

	/**
	 * 保存数据（插入或更新）
	 * 
	 * @param testData
	 */
	@Override
	@Transactional(readOnly = false)
	public void save(ZtBackImg ztBackImg) {
		super.save(ztBackImg);
		// 保存上传图片
		FileUploadUtils.saveFileUpload(ztBackImg.getId(), "user_upload2");
		//img

	
	}

	/**
	 * 保存数据（插入或更新）
	 * 
	 * @param testData
	 */

	@Transactional(readOnly = false)
	public void saveVideo(ZtBackImg ztBackImg) {
		super.save(ztBackImg);
		// 保存上传图片
		FileUploadUtils.saveFileUpload(ztBackImg.getId(), "user_upload2");
		
		// 保存上传附件
		FileUploadUtils.saveFileUpload(ztBackImg.getId(), "user_upload3");

	}

	/**
	 * 删除数据
	 * 
	 * @param testData
	 */
	@Override
	@Transactional(readOnly = false)
	public void delete(ZtBackImg ztBackImg) {
		super.delete(ztBackImg);
	}
	
	public String getImgFirst(ZtBackImg ztBackImg){
		return dao.getImgFirst(ztBackImg);
	}
	
}